package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.task.Task;
import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.TickerOrderDetailsEntity;
import com.zw.yzk.kabu.data.network.service.TicketOrderDetailsService;
import com.zw.yzk.kabu.data.network.task.TicketOrderDetailsTask;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/12.
 */

public class TicketOrderDetailsRepository extends CommonRepository {


    @Inject
    public TicketOrderDetailsRepository() {
    }


    @Override
    protected Observable connectServer(Task task) {
        TicketOrderDetailsService service = ServiceGenerator.createService(TicketOrderDetailsService.class);
        TicketOrderDetailsTask homePageTask = (TicketOrderDetailsTask) addToken(task);

        return service.getTicketOrderDetails(homePageTask.userId, homePageTask.accessToken, homePageTask.orderId);
    }

    @Override
    protected Func1<TickerOrderDetailsEntity, Observable> getServerData() {
        return new Func1<TickerOrderDetailsEntity, Observable>() {
            @Override
            public Observable call(TickerOrderDetailsEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
